﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_ReadMail]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_ReadMail];
GO
CREATE PROCEDURE [dbo].[sproc_ReadMail]
    @Doc_ID int
/*

============================================================
功能:    读邮件@Doc_ID
参数:
    @Doc_ID int        :    被读取的邮件ID
============================================================

*/
AS
BEGIN

SET NOCOUNT ON

SELECT
        a.DocID,
        a.ClassID,
        a.DocTitle,
        a.DocContent,
        a.DocType,
        a.DocAddedBy,
        a.DocAddedDate,
        a.DocAttribute,
        a.DocDeletion,
        b.Readed,
        b.Sender,
        b.Receiver,
        b.AllReceiver,
        b.CopySender,
        b.FurtiveCopySender,
        b.Position,
        c.FileID,
        c.[FileName],
        c.FileSize,
        c.FileAttribute,
        c.FileVisualPath,
        c.FileAuthor,
        c.FileCatlog,
        c.FileAddedDate,
        d.classname
    FROM
        uds_document a
        inner join uds_MailAttach b on a.docid = b.docid
        left outer join uds_files c on a.DocID = c.DocID
        left outer join uds_class d on a.classid = d.classid
    WHERE
        a.docid = @Doc_ID

UPDATE uds_mailattach SET readed = 1 WHERE docid = @Doc_ID

END
GO